/**
 * precedencepropagator.h is part of %PROJECTNAME%.
 *
 * %PROJECTNAME% is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * %PROJECTNAME% is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with %PROJECTNAME%.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef PRECEDENCEPROPAGATOR_H
#define PRECEDENCEPROPAGATOR_H

#include <gecode/int.hh>

class PrecedencePropagator : public Gecode::Propagator
{
public:
    PrecedencePropagator( Gecode::Space & a_home, Gecode::Int::IntView a_end, Gecode::Int::IntView a_start );
    PrecedencePropagator( Gecode::Space & a_home, bool a_share, PrecedencePropagator & a_other );
    virtual ~PrecedencePropagator();

    virtual size_t dispose( Gecode::Space & a_home );
    virtual PrecedencePropagator * copy( Gecode::Space & a_home, bool a_share );
    virtual Gecode::PropCost cost( const Gecode::Space & a_home, const Gecode::ModEventDelta & a_delta ) const;
    virtual Gecode::ExecStatus propagate( Gecode::Space & a_home, const Gecode::ModEventDelta & a_delta );

    static Gecode::ExecStatus post( Gecode::Space & a_home, Gecode::Int::IntView a_end, Gecode::Int::IntView a_start );

private:

    Gecode::Int::IntView m_end;     // End of a task.
    Gecode::Int::IntView m_start;   // Start of an other task.
};

void precedence( Gecode::Space & a_home, Gecode::IntVar a_end, Gecode::IntVar a_start );

#endif // PRECEDENCEPROPAGATOR_H
